package cn.itcast.controller;


import cn.itcast.entity.Order;


import cn.itcast.entity.PageBean;
import cn.itcast.entity.Result;
import cn.itcast.service.CastService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@Slf4j
public class CastController {
    @Autowired
    private CastService castService;

    //费用新增
    @PostMapping("/cast/add")
    public Result add(@RequestBody Order order) {
        castService.add(order);
        return Result.success();
    }
/*
    //费用修改
    @GetMapping("/Cast/{id}")
    public Result selectById(@PathVariable Integer id) {
        log.info("费用");
        Cast Cast = castService.selectById(id);
        return Result.success(Cast);
    }

    @PutMapping("/Cast")
    public Result update(@RequestBody Cast Cast) {
        log.info("根据id进行费用内容修改");
        castService.update(Cast);
        return Result.success();
    }*/
    //分页条件查询展示
    @GetMapping("/cast")
    public Result page(@RequestParam(defaultValue = "1") Integer page,
                       @RequestParam(defaultValue = "10") Integer pageSize,
                       String userName, String roomId) {
        log.info("带条件分页查询 ");
        PageBean pageBean = castService.page(page, pageSize, userName, roomId);
        return Result.success(pageBean);
    }
    //根据房间id进行查询
    @GetMapping("/cast/userId")
    public Result getMoney( Long userId) {
        log.info("根据用户id进行查询金额");
        Double money =castService.getMoney(userId);
        return Result.success(money);
    }



}
